#include <iostream>
#include <vector>
#include <string>
using namespace std;
class Solution
{
public:
    bool rotateString(string s, string goal)
    {
        int sLen = s.length(), goalLen = goal.length();
        string newGoal = "";
        int j = goal.find_first_of(s[0]);
        if (j != string::npos)
        {
            cout<<j<<endl;
            while (newGoal.length() != goalLen)
            {
                newGoal += goal[j];
                cout<<newGoal<<endl;
                j++;
                if (j + 1 > goalLen)
                {
                    j = 0;
                }
            }
        }
        return newGoal.compare(s)==0;
    }

    bool rotateString_2(string s, string goal) {
        int m = s.size(), n = goal.size();
        if (m != n) {
            return false;
        }
        for (int i = 0; i < n; i++) {
            bool flag = true;
            for (int j = 0; j < n; j++) {
                if (s[(i + j) % n] != goal[j]) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                return true;
            }
        }
        return false;
    }

};
int main()
{
    /**
     * @brief 
     * "bbbacddceeb"
    "ceebbbbacdd"
     * 
     */
    Solution s;
    string str = "bbbacddceeb", goal = "ceebbbbacdd";
    cout << s.rotateString(str, goal) << endl;
    system("pause");
    return 0;
}
